Kanzi  3.9.7
Kanzi Engine API
kanzi::ResourceProfilingPtreePopulator Struct Reference

Resource profiling ptree populator. More...

#include <kanzi/core.ui/resource/resource_profiling_ptree_populator.hpp>

Static Public Member Functions

static ptree populatePropertyTree (const ResourceProfilingAttributes &attributes)
 Populates property tree with resource profiling attributes. More...
 
static ptree populatePropertyTree (const ResourceProfilingContext &context)
 Populates property tree with resource profiling attributes of the context. More...
 
static ptree populatePropertyTree (const ResourceProfilingContextFactory &factory)
 Populates property tree with resource profiling attributes of the contexts stored in the context factory. More...
 
static ptree populatePropertyTree (const ResourceProfilingDataSample &dataSample)
 Populates property tree with attributes of resource profiling data sample. More...
 
static ptree populatePropertyTree (const ResourceProfilingDataSample::Factory &factory)
 Populates property tree with attributes of resource profiling data samples stored in the data sample factory. More...
 
static ptree populatePropertyTree (const ResourceProfiler &profiler)
 Populates property tree with attributes of all the profiling data stored in profiler. More...
 

Detailed Description

Resource profiling ptree populator.

This class provides functions to populate boost ptree with resource profiling data.

Example

To populate ptree with resource profiling data.

#include <kanzi/kanzi.hpp>
#include <boost/property_tree/json_parser.hpp>
using namespace kanzi;
class ResourceProfilingPtreePopulatorExample : public Application
{
protected:
void onShutdown() override
{
// Populate ptree with profiling data.
ptree resourceProfilingDataTree = ResourceProfilingPtreePopulator::populatePropertyTree(getResourceManager()->getResourceProfiler());
// Write ptree in json format to string stream.
stringstream ss;
boost::property_tree::json_parser::write_json(ss, resourceProfilingDataTree);
// Boost json_writer considers "/" as escape character and adds "\" before each "/".
// This affects how kzb urls are displayed.
// The following code outputs json to cout replacing "\/" with "/".
string str(ss.str());
string_view strView(str);
while (!strView.empty())
{
size_t backSlashPos = strView.find("\\/");
if (backSlashPos == string_view::npos)
{
cout << strView;
strView = string_view();
continue;
}
cout << strView.substr(0, backSlashPos);
strView = strView.substr(backSlashPos + 1);
}
cout << "\n";
}
};

Member Function Documentation

static ptree kanzi::ResourceProfilingPtreePopulator::populatePropertyTree ( const ResourceProfilingAttributes attributes)
static

Populates property tree with resource profiling attributes.

Parameters
attributesThe resource profiling attributes.
Returns
The property tree populated with resource profiling attributes.
static ptree kanzi::ResourceProfilingPtreePopulator::populatePropertyTree ( const ResourceProfilingContext context)
static

Populates property tree with resource profiling attributes of the context.

Parameters
contextThe resource profiling context.
Returns
The property tree populated with resource profiling attributes of the context.
static ptree kanzi::ResourceProfilingPtreePopulator::populatePropertyTree ( const ResourceProfilingContextFactory factory)
static

Populates property tree with resource profiling attributes of the contexts stored in the context factory.

This function creates new unnamed ptree node for each context and calls populatePropertyTree() function to populate that ptree node with context attributes. The new ptree node is then added to propertyTree.

Parameters
factoryThe resource profiling context factory.
Returns
The property tree populated with resource profiling attributes of the contexts stored in the context factory.
static ptree kanzi::ResourceProfilingPtreePopulator::populatePropertyTree ( const ResourceProfilingDataSample dataSample)
static

Populates property tree with attributes of resource profiling data sample.

Parameters
dataSampleThe resource profiling data sample.
Returns
The property tree populated with attributes of resource profiling data sample.
static ptree kanzi::ResourceProfilingPtreePopulator::populatePropertyTree ( const ResourceProfilingDataSample::Factory factory)
static

Populates property tree with attributes of resource profiling data samples stored in the data sample factory.

This function creates new unnamed ptree node for each data sample and calls populatePropertyTree() function to populate that ptree node with data sample attributes. The new ptree node is then added to propertyTree.

Parameters
factoryThe resource profiling data samples factory.
Returns
The property tree populated with attributes of resource profiling data samples stored in the data sample factory.
static ptree kanzi::ResourceProfilingPtreePopulator::populatePropertyTree ( const ResourceProfiler profiler)
static

Populates property tree with attributes of all the profiling data stored in profiler.

This function creates a new ptree node for each resource profiling context factory and calls the populatePropertyTree() function to populate that node with profiling data stored in context factory. The name of that ptree node is set to the name of the loading thread to which the resource profiling context factory belongs. Each context factory ptree node is then added as a child to the node named "ThreadContexts" which is in turn added as a child to the root of the resulting ptree.

This function creates a new ptree node named "ResourceProfilingDataSamples". That node is populated with the populatePropertyTree() function called for the profiling data sample factory owned by profiler. To access the profiling data sample factory use the ResourceProfiler::getResourceProfilingDataSampleFactory() function.

Parameters
profilerThe resource profiler.
Returns
The property tree populated with attributes of all the profiling data stored in profiler.

The documentation for this struct was generated from the following file: